This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.
Try executing this chunk by clicking the Run button within the chunk or by placing your cursor inside it and pressing Ctrl+Shift+Enter.
library(tidyverse)
Registered S3 methods overwritten by 'dbplyr':
method from
print.tbl_lazy
print.tbl_sql
-- Attaching packages ----------------------------------------------------------------------------------------------------------------------- tidyverse 1.3.2 --
v ggplot2 3.3.6 v purrr 0.3.4
v tibble 3.1.8 v dplyr 1.0.10
v tidyr 1.2.1 v stringr 1.4.1
v readr 2.1.2 v forcats 0.5.2
-- Conflicts -------------------------------------------------------------------------------------------------------------------------- tidyverse_conflicts() --
x dplyr::filter() masks stats::filter()
x dplyr::lag() masks stats::lag()
Warning message:
R graphics engine version 15 is not supported by this version of RStudio. The Plots tab will be disabled until a newer version of RStudio is installed.
library(ggplot2)
capacity <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2022/2022-05-03/capacity.csv')
Rows: 49 Columns: 7
-- Column specification ----------------------------------------------------------------------------------------------------------------------------------------
Delimiter: ","
chr (1): type
dbl (6): year, standalone_prior, hybrid_prior, standalone_new, hybrid_new, total_gw
i Use `spec()` to retrieve the full column specification for this data.
i Specify the column types or set `show_col_types = FALSE` to quiet this message.
g <- ggplot(data=capacity %>% filter(type == "Solar")) + geom_line(aes(x=year,y=total_gw))
print(g)
g <- ggplot(data=capacity %>% filter(type %in% c("Solar","Wind","Storage"))) + geom_line(aes(x=year,y=total_gw,color=type))
print(g)
g <- ggplot(data=capacity %>% filter(type %in% c("Solar","Wind","Storage"))) +
# Graph and Aesthetics
geom_line(aes(x=year,y=total_gw,color=type),size=1.5) +
# Labels
ylab("Total Gigawatts") +
xlab("Year") +
labs(color = "Energy Type")+
# Scales and limits
scale_x_continuous(breaks = seq(2014,2020, by=1))+
scale_y_continuous(limits = c(0,500))+
# Theme
theme_minimal()+
theme(plot.title=element_text(size = 16, face = "bold"),
axis.text=element_text(size=12),
axis.title=element_text(size=14,face="bold"))+
# Title
ggtitle("Growth of Renewable Energy Sources")
print(g)
ggsave("output/growth-little.png",width=1500,height=1500, units = "px")
library(plotly)
Registered S3 method overwritten by 'data.table':
method from
print.data.table
Registered S3 method overwritten by 'htmlwidgets':
method from
print.htmlwidget tools:rstudio
Attaching package: ‘plotly’
The following object is masked from ‘package:ggplot2’:
last_plot
The following object is masked from ‘package:stats’:
filter
The following object is masked from ‘package:graphics’:
layout
ggplotly(g)